package dao

import (
	"testing"
	"www.bwbdim.com/internal/dto"
	"www.bwbdim.com/internal/model"
	"github.com/stretchr/testify/assert"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"gorm.io/gorm/logger"
	"log"
	"os"
)

func TestDebugSQL(t *testing.T) {
	// Create a real database connection to see the SQL
	dsn := "user:pass@tcp(localhost:3306)/test?charset=utf8mb4&parseTime=True&loc=Local"
	db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{
		Logger: logger.New(
			log.New(os.Stdout, "\r\n", log.LstdFlags),
			logger.Config{
				LogLevel: logger.Info,
			},
		),
	})
	if err != nil {
		t.Skip("Database connection not available")
		return
	}

	// Create a mock table structure
	type Users struct {
		Id       int
		Username string
		Nickname string
		Active   string
	}

	req := dto.LoginReq{
		Username: "testuser",
		Password: "testpass",
	}

	var user Users
	
	// This will print the actual SQL generated
	db.Select("id,username,nickname,active").
		Where("username = ? and password = ?", req.Username, req.Password).
		First(&user)
	
	t.Log("Debug completed")
}